package com.muki.spider.core;

import java.util.Iterator;

import org.springframework.stereotype.Component;

@Component
public class SpiderFactoryIterator implements Iterator<PackSpider> {

	private SpiderFactory factory;
	private int index;
	
	public SpiderFactoryIterator(SpiderFactory factory) {
		this.factory = factory;
		this.index = 0;
	}
	
	@Override
	public boolean hasNext() {
		if(index<factory.getLength())
			return true;
		return false;
	}

	@Override
	public PackSpider next() {
		PackSpider spider = factory.getSpider(index);
		index++;
		return spider;
	}

}
